#include "./../Include/public.h"
void add_course()
{
	printf("输入学生信息：\n");
	printf("模式:课程号 课程名称 课程性质 学时 学分 课程已选人数 课程人数上线\n");
	struct course* node = (struct course*)malloc(sizeof(struct course));
	scanf("%d %s %s %d %d %d %d",&node->cno,node->cname,node->type,&node->ctime,&node->score,&node->chose,&node->limit);
	
	FILE *f;
 	f = fopen("./data/log.log", "a+");
       time_t now ;
       struct tm *tm_now ;
       time(&now) ;
       tm_now = localtime(&now) ;
  		fprintf(f,"datetime: %d-%d-%d %d:%d:%d\n",tm_now->tm_year+1900, tm_now->tm_mon+1, tm_now->tm_mday, tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec) ;
  	fprintf(f, "add course: %d\n",node->cno);
  	fclose(f);
	
	if (head_course == NULL) {
		head_course = node;
	} else {
		struct course *p = head_course;
		struct course *q = p;
		while (p != NULL) {
			if (p->cno == node->cno) {
				printf("学生已存在！\n");
				return ;
			}
			q = p;	
			p = p->next;
		}
		q->next = node;
		node->next = NULL; 
	}
}
